/*
 * @lc app=leetcode.cn id=349 lang=cpp
 *
 * [349] 两个数组的交集
 */

// @lc code=start
class Solution {
public:
    vector<int> intersection(vector<int>& nums1, vector<int>& nums2) {
        set<int> memo;
        for(auto x : nums1) memo.insert(x);
        set<int> ans_set;
        vector<int> ans;
        for(auto x : nums2)
            if(memo.find(x) != memo.end()) ans_set.insert(x);
        for(auto x : ans_set)   ans.push_back(x);
        return ans;
    }
};
// @lc code=end

